import { useEffect, useState } from "react"
import { fetchChannelApi, type ChannelItem } from "../../apis/list"

function useTabs() {
    const [channels, setChannels] = useState<ChannelItem[]>([])
    useEffect(() => {
        const getChannels = async () => {
            try {
                const res = await fetchChannelApi()
                setChannels(res.data.data.channels)
            } catch(e) {
                throw new Error('fetch channel error')
            }
        }
        getChannels()
    }, [])

    return {
        channels
    }
}

export {useTabs}